<template>
  <div id="browser-container">
    <browser-toolbar @change-url="updateIframeUrl" @navigate="handleNavigation"/>
<!--    <iframe :src="iframeUrl" frameborder="0" ref="iframe" class="iframe-content"></iframe>-->
  </div>
</template>

<script>
import BrowserToolbar from './BrowserToolbar.vue';

export default {
  components: {
    BrowserToolbar
  },
  data() {
    return {
      iframeUrl: 'https://example.com' // 初始URL
    };
  },
  methods: {
    updateIframeUrl(newUrl) {
      this.iframeUrl = newUrl;
    },
    handleNavigation(action) {
      const iframe = this.$refs.iframe.contentWindow;
      if (action === 'back') {
        iframe.history.back();
      } else if (action === 'forward') {
        iframe.history.forward();
      } else if (action === 'refresh') {
        iframe.location.reload();
      }
    }
  }
};
</script>

<style>
#iframe-content {
  width: 100%;
  height: calc(100vh - 48px); /* 减去工具栏的高度 */
  margin-top: 48px;
  border: none;
}
</style>
